var query = function(){
	asyncSubmit("produceManagerDetailForm");
};

/*========================================生产方式操作==============================================*/
var toAddProducePlan = function(){
	//添加生产方式弹窗
	$.box('.onlyuserforaddtaskalertbox', {
		onOpen : function() {
			
		}
	}, {
		submit:{
			close:false,
			dom:['#saveProducePlan'],
			fun:function(index){
				var currObj = this;
				saveProducePlan(function(){					
					currObj.close(index);
				});
				
			}
		},
		close : {
			dom : [ '.onlyuserforaddtaskalertbox .closeforaddtask','.onlyuserforaddtaskalertbox .c_but_no' ]
		}
	});
	
};

//添加生产方式
var saveProducePlan = function(callback){
	//验证
	if(validate()){		
		var fun = function(msg) {
			if (msg.result == "success") {
				if(callback){
					callback();
				}
				layer.msg("保存生产方式成功！",1,9,function(){
					query();
				});
			} else {
				layer.alert(msg.result);
			};
		};
		ajaxCommFunWithDataType(globePath+"/producePlan/submitPProducePlan.htm", $("#addProducePlanForm").serialize(),'json',fun);
	}
};
//验证
var validate = function(){
	var proPlanName = $.trim($("#proPlanName").val());
	if(proPlanName==''){
		layer.msg("生产方式不能为空");
		return false;
	}
	var price = $.trim($("#price").val());
	if(price==''){
		layer.msg("生产计价不能为空");
		return false;
	}
	var count = $.trim($("#count").val());
	if(count==''){
		layer.msg("生产计价数量不能为空");
		return false;
	}
	var unit = $.trim($("#unit").val());
	if(unit==''){
		layer.msg("单位不能为空");
		return false;
	}
	return true;
};
